# cmake_minimum_required(VERSION 3.5)
# project(example_package)

# # Default to C99
# if(NOT CMAKE_C_STANDARD)
#   set(CMAKE_C_STANDARD 99)
# endif()

# # Default to C++14
# if(NOT CMAKE_CXX_STANDARD)
#   set(CMAKE_CXX_STANDARD 14)
# endif()

# if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
#   add_compile_options(-Wall -Wextra -Wpedantic)
# endif()

# # find dependencies
# find_package(ament_cmake REQUIRED)
# find_package(rclcpp REQUIRED)

# if(BUILD_TESTING)
#   find_package(ament_lint_auto REQUIRED)
#   # the following line skips the linter which checks for copyrights
#   # uncomment the line when a copyright and license is not present in all source files
#   #set(ament_cmake_copyright_FOUND TRUE)
#   # the following line skips cpplint (only works in a git repo)
#   # uncomment the line when this package is not in a git repo
#   #set(ament_cmake_cpplint_FOUND TRUE)
#   ament_lint_auto_find_test_dependencies()
# endif()

# ament_package()


cmake_minimum_required(VERSION 3.5)
project(example_package)
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

SET(CMAKE_BUILD_TYPE "RELEASE")
SET(CMAKE_CXX_FLAGS "-O2 -g ${CMAKE_CXX_FLAGS}")

find_package(ament_cmake_auto REQUIRED)
find_package(OpenCV REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(PCL REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(pcl_conversions REQUIRED)

ament_auto_find_build_dependencies()

include_directories(
  include
  ${OpenCV_INCLUDE_DIRS}
  ${PCL_INCLUDE_DIRS}
)


############### listener node ###############

ament_auto_add_library(${PROJECT_NAME}_listener_node SHARED
  include/listener.hpp
  src/listener.cpp
)

target_link_libraries(${PROJECT_NAME}_listener_node ${OpenCV_LIBRARIES} ${PCL_LIBRARIES} ${cv_bridge_LIBRARIES})

rclcpp_components_register_node(${PROJECT_NAME}_listener_node
  PLUGIN "mars_rover::listener::ListenerNode"
  EXECUTABLE ${PROJECT_NAME}_listener_exe
)

############### talker node ###############

ament_auto_add_library(${PROJECT_NAME}_talker_node SHARED
  include/talker.hpp
  src/talker.cpp
)

target_link_libraries(${PROJECT_NAME}_talker_node  ${OpenCV_LIBRARIES} ${PCL_LIBRARIES} ${cv_bridge_LIBRARIES})


rclcpp_components_register_node(${PROJECT_NAME}_talker_node
  PLUGIN "mars_rover::talker::TalkerNode"
  EXECUTABLE ${PROJECT_NAME}_talker_exe
  # 此处是让结点生成可执行文件，上边是结点的位置，下边是可执行文件名，命名方式是工程名+_talker_exe
)

# INSTALL
ament_auto_package(INSTALL_TO_SHARE launch param)